package com.gientech.loancenter.mq;

import com.alibaba.fastjson.JSON;
import com.gientech.loancenter.mq.enity.LoanMessage;
import com.gientech.loancommon.core.LoanTopic;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = LoanTopic.LOAN_MESSGAE,consumerGroup = "loan-consumer-group")
@Slf4j
public class LoanMessageConsumer implements RocketMQListener<String> {

    @Override
    public void onMessage(String res) {
        LoanMessage loanMessage = JSON.toJavaObject(JSON.parseObject(res), LoanMessage.class);
        log.info("发送短信给{},短信内容{}",loanMessage.getMobile(),loanMessage.getMessage());
    }
}
